package com.moyu.user.controller;

import com.moyu.common.core.controller.BaseController;
import com.moyu.common.core.domain.R;
import com.moyu.common.core.domain.TableDataInfo;
import com.moyu.user.domain.permission.dto.PermissionQueryDTO;
import com.moyu.user.domain.permission.dto.PermissionSaveDTO;
import com.moyu.user.service.IPermissionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 权限控制器
 *
 * @Author 赵彦博
 * @Date 2025/3/25 18:28
 */
@RestController
@RequestMapping("/permission")
@Tag(name = "权限接口")
public class PermissionController extends BaseController {

    @Autowired
    private IPermissionService permissionService;

    @GetMapping("/list")
    public TableDataInfo list(PermissionQueryDTO permissionQueryDTO) {
        return getTableDataInfo(permissionService.list(permissionQueryDTO));
    }

    @DeleteMapping("/{permissionId}")
    public R deletePermission(@PathVariable Long permissionId) {
        return toR(permissionService.deletePermission(permissionId));
    }

    @PostMapping("/add")
    public R addPermission(@RequestBody PermissionSaveDTO permissionSaveDTO) {
        return toR(permissionService.addPermission(permissionSaveDTO));
    }
}
